<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <h2>Pesquisar Horário</h2>

            <p:panel styleClass="container_24 clearfix " style="background: none; border: none;"> 
                <h:form id="form" acceptcharset="utf-8">
                    <p:growl id="msg" life="3000" autoUpdate="true" showDetail="false"/>

                    <p class="subtitle">Dados Gerais</p>

                    <p:outputLabel value="Dias:" styleClass="grid_3" for="diasSelectManyMenu" />
                    <p:selectManyButton id="diasSelectManyMenu"
                                        value="#{managerPesquisarHorario.diasSemanasSelecionadasPesquisar}" 
                                          styleClass="grid_8" converter="enumconverter" >

                        <f:selectItems value="#{managerPesquisarHorario.diasSemana}" />
                    </p:selectManyButton>

                    <p:outputLabel value="Horário:" styleClass="grid_3" for="horarioCalendar" />
                    <p:calendar id="horarioCalendar" value="#{managerPesquisarHorario.horario}"
                                locale="pt" yearRange="1700:2100" maxHour="22" minHour="6" 
                                timeOnly="true" navigator="true" pattern="HH:mm" styleClass="grid_9" />

                    <div class="clear"/>

                    <div class="buttonAction">
                        <p:commandButton value="Pesquisar" icon="ui-icon-search" 
                                         actionListener="#{managerPesquisarHorario.pesquisar()}" 
                                         update="@form" styleClass="ui-priority-primary"/>
                    </div>
                    
                    <p class="subtitle">Resultado</p>

                    <p:dataTable id="cursoDataTable" value="#{managerPesquisarHorario.horarios}" var="item"
                                 styleClass="grid_24" emptyMessage="Nenhum registro">

                        <f:facet name="header">
                            Horários
                        </f:facet>

                        <p:column headerText="Ação" width="50">
                            <p:button title="Editar"
                                      href="editarhorario.xhtml?eHorario=#{item.id}"
                                      icon="ui-icon-pencil"/>
                            <p:button title="Visualizar"
                                      href="visualizarhorario.xhtml?vHorario=#{item.id}"
                                      icon="ui-icon-zoomin"/>
                            <p:commandButton update="@form" title="Excluir"
                                             oncomplete="dlg.show()"
                                             icon="ui-icon-trash" >
                                <f:setPropertyActionListener target="#{managerPesquisarHorario.horarioDeletar}" value="#{item}" />
                            </p:commandButton>
                        </p:column>

                        <p:column headerText="Dias da Semana" style="text-align: center">
                            #{'| '}
                            <ui:repeat value="#{item.itemHorario}" var="itemHorario">
                                #{itemHorario.diaSemana.sigla.concat(' | ')}
                            </ui:repeat>
                        </p:column>

                        <p:column headerText="Horário" style="text-align: center">
                            #{managerPesquisarHorario.formatarDataHorario(item.itemHorario.get(0))}
                        </p:column> 

                    </p:dataTable>

                    <div class="buttonAction">
                        <p:button value="Voltar" icon="ui-icon-circle-arrow-w"
                                  href="indexhorario.xhtml"/>
                    </div>

                    <p:dialog id="modalDialog" header="Confirmação de remoção" widgetVar="dlg" modal="true" 
                              height="80" closable="true" resizable="false" >
                        <h:outputText value="Tem certeza que deseja remover este horário?" />
                        <div class="buttonAction">
                            <p:commandButton value="Sim"
                                             actionListener="#{managerPesquisarHorario.deletar()}"
                                             update="@form"
                                             icon="ui-icon-check"/>
                            <p:commandButton value="Não" icon="ui-icon-close"
                                             oncomplete="dlg.hide()" />

                        </div>
                    </p:dialog>
                    
                </h:form>
            </p:panel> 
        </ui:define>
    </ui:composition>
</html>